package com.sxt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.sxt.domain.User;
import com.sxt.service.UserService;
import com.sxt.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 用户业务接口实现
*/
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;

    /**
     * 用户登录
     *
     * @param loginName
     * @param loginPwd
     * @return
     */
    @Override
    public User queryUser(String loginName, String loginPwd) {

        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getLoginName, loginName).eq(User::getLoginPwd, loginPwd);

        User user = userMapper.selectOne(queryWrapper);
        return user;
    }

    /**
     * 修改用户信息
     *
     * @param updateUser
     * @return
     */
    @Override
    public int updatePwd(User updateUser) {
        int count = userMapper.updateById(updateUser);
        return count;
    }
}
